home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT39.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.3 KB  |  80 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 39                         
  5.                                                                               
  6.  Demonstrates the wfastputpixel routine.                                     
  7.  Move the mouse around to create pixel trails.                               
  8.                                                                               
  9.  *** PROJECT ***                                                             
  10.  This program requires the WGT5_WC.LIB file to be linked.                    
  11.                                                                               
  12.  *** DATA FILES ***                                                          
  13.  DEFAULT.PAL must be in your executable directory.                              
  14.                                                            WATCOM C++ VERSION 
  15. ==============================================================================
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <conio.h>
  20. #include <wgt5.h>
  21.  
  22.  
  23. #define NUMPIX 1000
  24.  
  25. short x, y, i, j;
  26. short px[NUMPIX+1], py[NUMPIX+1];
  27. color pal[256];
  28.  
  29. void main(void)
  30. {
  31.   
  32.   printf ("WGT Example #39\n\n");
  33.   printf ("Pixel trails are created by memorizing mouse positions.\n");
  34.   printf ("Click the RIGHT mouse button to end the program.\n");
  35.   printf ("\n\nPress any key to continue.\n");
  36.   getch ();
  37.  
  38.   vga256 ();
  39.   wloadpalette ("default.pal", pal);
  40.   wsetpalette (0, 255, pal);
  41.  
  42.   minit ();
  43.   for (i = 0; i <= NUMPIX; i++)
  44.   {
  45.     px[i] = 0;
  46.     py[i] = 0;
  47.   }
  48.  
  49.   do {
  50.     wsetcolor (0);
  51.     wretrace ();
  52.     for (i = NUMPIX; i >= 1; i--)
  53.     {
  54.       px[i] = px[i - 1];
  55.       py[i] = py[i - 1];
  56.     }
  57.     wsetcolor (0);
  58.     wfastputpixel (px[NUMPIX], py[NUMPIX]);
  59.     wfastputpixel (319 - px[NUMPIX], 199 - py[NUMPIX]);
  60.  
  61.  
  62.     wsetcolor (0);
  63.     wfastputpixel (px[0], py[0]);
  64.     wfastputpixel (319 - px[0], 199 - py[0]);
  65.  
  66.     px[0] = mouse.mx;
  67.     py[0] = mouse.my;
  68.  
  69.     for (i = 0; i < NUMPIX; i++)
  70.     {
  71.       wsetcolor (i);
  72.       wfastputpixel (px[i], py[i]);
  73.       wfastputpixel (319 - px[i], 199 - py[i]);
  74.     }
  75.   } while (mouse.but != 2);
  76.   mdeinit ();
  77.   wsetmode (3);
  78. }
  79.  
  80.